{% extends 'generic/object_edit.html' %}
{% load static %}
{% load form_helpers %}
{% load helpers %}

{% block tabs %}
    {% if not obj.pk %}
        {% include 'ipam/inc/ipadress_edit_header.html' with active_tab='add' %}
    {% endif %}
{% endblock %}

{% block form %}
    <div class="panel panel-default">
        <div class="panel-heading"><strong>IP Address</strong></div>
        <div class="panel-body">
            {% render_field form.address %}
            {% render_field form.status %}
            {% render_field form.role %}
            {% render_field form.vrf %}
            {% render_field form.dns_name %}
            {% render_field form.description %}
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><strong>Tenancy</strong></div>
        <div class="panel-body">
            {% render_field form.tenant_group %}
            {% render_field form.tenant %}
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <strong>Interface Assignment</strong>
        </div>
        <div class="panel-body">
            {% with vm_tab_active=form.initial.vminterface %}
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation"{% if not vm_tab_active %} class="active"{% endif %}><a href="#device" role="tab" data-toggle="tab">Device</a></li>
                    <li role="presentation"{% if vm_tab_active %} class="active"{% endif %}><a href="#virtualmachine" role="tab" data-toggle="tab">Virtual Machine</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane{% if not vm_tab_active %} active{% endif %}" id="device">
                        {% render_field form.device %}
                        {% render_field form.interface %}
                    </div>
                    <div class="tab-pane{% if vm_tab_active %} active{% endif %}" id="virtualmachine">
                        {% render_field form.virtual_machine %}
                        {% render_field form.vminterface %}
                    </div>
                </div>
            {% endwith %}
            {% render_field form.primary_for_parent %}
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><strong>NAT IP (Inside)</strong></div>
        <div class="panel-body">
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#by_device" aria-controls="home" role="tab" data-toggle="tab">By Device</a></li>
                <li role="presentation"><a href="#by_vm" aria-controls="search" role="tab" data-toggle="tab">By VM</a></li>
                <li role="presentation"><a href="#by_vrf" aria-controls="search" role="tab" data-toggle="tab">By IP</a></li>
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="by_device">
                    {% render_field form.nat_region %}
                    {% render_field form.nat_site %}
                    {% render_field form.nat_rack %}
                    {% render_field form.nat_device %}
                </div>
                <div class="tab-pane" id="by_vm">
                    {% render_field form.nat_cluster %}
                    {% render_field form.nat_virtual_machine %}
                </div>
                <div class="tab-pane" id="by_vrf">
                  {% render_field form.nat_vrf %}
                </div>
            </div>
            {% render_field form.nat_inside %}
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><strong>Tags</strong></div>
        <div class="panel-body">
            {% render_field form.tags %}
        </div>
    </div>
    {% if form.custom_fields %}
        <div class="panel panel-default">
            <div class="panel-heading"><strong>Custom Fields</strong></div>
            <div class="panel-body">
                {% render_custom_fields form %}
            </div>
        </div>
    {% endif %}
{% endblock %}
